<!-- 弹出层 -->
<template>
	<view class="">
		<button class="button" type="primary" @tap="toggle('top')"><text class="button-text">顶部弹出</text></button>
		<button class="button mt20" type="primary" @tap="toggle('center')"><text class="button-text">中间弹出</text></button>
		<button class="button mt20" type="primary" @tap="toggle('bottom')"><text class="button-text">底部弹出</text></button>
		<uni-section title="自定义弹出层" type="line"></uni-section>
		<!-- success  error warn info -->
		<button class="button popup__info" @click="toggleMessage('info')"><text class="button-text">信息</text></button>
		<!-- 消息提示 -->
		<uni-popup id="popup" ref="popup" :type="type" :animation="true">
			<view class="popup-content bgff ">
				popup 内容，此示例没有动画效果
				<button @tap="close_pup">关闭</button>
			</view>
		</uni-popup>
		<!-- 消息提示 -->
		<uni-popup id="popupMessage" ref="popupMessage" type="message" @change="change">
			<uni-popup-message :type="msgType" :message="message" :duration="2000"></uni-popup-message>
		</uni-popup>
		<uni-popup id="popupDialog" ref="popupDialog" type="dialog" @change="change">
			<uni-popup-dialog :type="msgType" title="通知" content="欢迎使用 uni-popup!" :before-close="true" @confirm="dialogConfirm"
			 @close="dialogClose"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				type: 'bottom',
				msgType: "",
				message: '8888'
			}
		},
		components: {},
		methods: {
			toggle(type) {
				this.type = type
				this.$refs.popup.open()
			},
			close_pup() {
				this.$refs.popup.close()
			},
			dialogConfirm() {
				this.$refs.popupDialog.close()
			},
			dialogClose() {
				this.$refs.popupDialog.close()
			},
			toggleMessage(type) {
				this.msgType = type
				switch (type) {
					case 'success':
						this.message = '这是一条成功消息提示'
						break
					case 'warn':
						this.message = '这是一条警告消息提示'
						break
					case 'info':
						this.message = '这是一条消息提示'
						break
					case 'error':
						this.message = '这是一条错误消息提示'
						break
				}
				this.$refs.popupDialog.open()
			},
		},
		mounted() {}
	}
</script>
<style scoped>
	.popup-content {
		min-height: 400rpx;
	}
</style>
